/*
    这是Tim自己开发的c容器库“tim_STL"，
    将想放入的元素放入type的union中便可开箱即用，不过需要传入接口强转，
    返回值需要取成员，
    其中，main.c 为主测试程序。
*/

#include "./tim.h"

void list_test()
{
    list my_list = list_init(my_list, 5);
    
    list_put(my_list, 1, (type)999);
    printf("get:%d\n", list_get(my_list, 1).Int);
    printf("se:%d\n", list_search(my_list, (type)0));
    list_insert(my_list, 4, (type)666);
    list_remove(my_list, 5);
    list_free(my_list);

    return;
}
void vector_test()
{
    vector my_vector = vector_init(my_vector, 5);

    for(int i = 0; i < 5; i++) 
        vector_put(my_vector, i, (type)(i * i));
    printf("find:%d\n", vector_find(my_vector,3).Int);
    printf("se:%d\n", vector_search(my_vector,(type)16));
    vector_insert(my_vector, 3, (type)999);
    vector_remove(my_vector, 0);
    vector_free(my_vector);

    return;
}
void stack_test()
{
    stack my_stack = stack_init(my_stack, 5);

    for (int i = 0; i < 6; i++) 
        stack_push(my_stack, (type)(i + 1));
    for (int i = 0; i < my_stack->size; i++) 
        printf("pop %d:%d\n", i, stack_pop(my_stack).Int);
    stack_free(my_stack);

    return;
}
void queue_test()
{
    queue my_queue = queue_init(my_queue, 5);

    for (int i = 0; i < 5; i++)
        queue_in(my_queue, (type)(i + 1));
    for (int i = 0; i < 5; i++)
        printf("out %d:%d\n", i, queue_out(my_queue).Int);
    queue_free(my_queue);

    return;
}
void bintree_test()
{
    bintree my_bintree = bintree_init(my_bintree, 5);

    return;
}
int main()
{
    int n;

    /*printf("Which data-structure you want to test:\n");
    scanf("%d", &n);

    switch (n) {
        case 1:
            vector_test();
            break;
        case 2:
            list_test();
            break;
        case 3:
            break;
        default:
            break;
    }*/
    /*vector_test();
    list_test();
    stack_test();
    queue_test();
    //anti_poland();*/
    bintree_test();
    printf("\nTest over!");

    return 0;
}